﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Web;

namespace Zuoye
{
    public class DbHelper
    {
        public static DataSet Query(string sql)
        {
            SqlConnection connection = new SqlConnection("Data Source=.;Initial Catalog=Zuoye;Integrated Security=True;");
            SqlDataAdapter sqlDataAdapter = new SqlDataAdapter(sql, connection);
            DataSet ds = new DataSet();
            //填充容器
            sqlDataAdapter.Fill(ds);
            //数据绑定
            return ds;
        }
        public static int ExecuteSql(string sql)
        {
            SqlConnection connection = new SqlConnection("Data Source=.;Initial Catalog=Zuoye;Integrated Security=True;");
            SqlCommand cmd = new SqlCommand(sql, connection);
            connection.Open();
            int flag = cmd.ExecuteNonQuery();
            connection.Close();
            return flag;

        }
    }
}